<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$export = $base_url;
$export['action'] = 'export';

?>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<table class="searchContent">
		<tbody>
			<tr>
			
			<td>
				
				<label>从</label>
			<input type="text" class="date" datefmt="yyyy-MM-dd HH:ss" name="start_date" value="<?php echo isset($param['start_date'])?$param['start_date']:date('Y-m-d',$start_day);?>" /> 00:00:00- 
			<input type="text" class="date" datefmt="yyyy-MM-dd HH:ss" name="end_date" value="<?php echo isset($param['end_date'])?$param['end_date']:date('Y-m-d',$end_day);?>" /> 23:59:59</td>
			<td>
			<label>统计周期</label>
			<input type="text" name="secnum" value="<?php echo isset($param['secnum'])?$param['secnum']:6;?>" /> 
			</td>
			</tr>
			<tr>
			
		</tr></tbody></table>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			总计费时长:<?php echo $count[0]['billsec']?>秒:<?php echo $count[0]['secnum']?>个<?php echo isset($param['secnum'])?$param['secnum']:6;?>秒   成本:<?php echo $count[0]['cost']?>元  费用:<?php echo $count[0]['fees']?>元  利润:<?php echo $count[0]['fees']-$count[0]['cost']?>元
		
			<li class="line">line</li>
			
		</ul>
	</div>
	<table class="table" width="1200" layoutH="158">
		<thead>
			<tr>
				
				<th width="5%" >代理商</th>
				<th width="5%" >计费时长(秒)</th>
				<th width="5%" >	6秒个数</th>
				<th width="5%" >成本(元)</th>
				<th width="5%" >消费(元)</th>
				<th width="5%" align="center" >	利润(元) 	</th>
				<th width="5%" >短信数量</th>
				<th width="5%" >短信费用</th>
				<th width="5%">vip次数</th>
				<th width="5%">积分奖励</th>
				<th width="5%">套餐利润</th>
				
			</tr>
		</thead>
		<tbody>
		
			<?php foreach ($data as $k=>$v):?>
		
			<tr target="id" >
				
				<td><?php echo Acct::getacctName($v['agent_id'])?></td>
				<td><?php echo $v['billsec']?></td>
				<td><?php echo $v['secnum']?> </td>
				<td><?php echo sprintf('%f',$v['cost'])?></td>
				<td><?php echo sprintf('%f',$v['fees'])?></td>
				<td><?php echo sprintf('%f',$v['fees']-$v['cost'])?></td>
				<?php 
					$acct = Acct::find('id = ?',$v['agent_id'])->getOne();
					$smscount = $acct->getAcctSmsCount($start_day,$end_day+86399);
				?>
				<td><?php echo $smscount;?> </td>
				<td><?php echo $smscount*$acct->smsbalance?> </td>
				<?php $vipcount = Acctbgpaylog::find("agent_id = ? and class = ? and created>=? and created<?",$v['agent_id'],'vip',($start_day),($end_day.' 23:59:59'))->getCount('id');
					$sco = Wapscorelog::find('agent_id = ? and type= 0 and created>=? and created<?',$v['agent_id'],$start_day,$end_day.' 23:59:59')->getsum('money');
				
				?>
				<td><?php echo $vipcount;?></td>
				<td><?php echo $sco;?></td>
				<td><?php 
				if($k == 0)
				{
					echo $packagemoney;
				}else{
					echo 0;
				}
				?></td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	
</div>